package com.example.aicloud.utils;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import org.springframework.validation.BindException;

/**
 * @Description: TODO
 * @Author Mr.Tang
 */

@RestControllerAdvice
public class ExceptionAdvice {

    @ExceptionHandler(BindException.class)
    public Result handleBindException(BindException e) {
        return Result.fail(e.getBindingResult().getAllErrors().get(0).getDefaultMessage());
    }

    @ExceptionHandler(Exception.class)
    public Result handelException(Exception e) {
        return Result.fail(e.getMessage());
    }



}
